package com.tinusgraglin.enclusiv.ui.viewmodel

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.tinusgraglin.enclusiv.Util
import com.tinusgraglin.enclusiv.datalayer.repos.UserRepo

class ArticleActivityViewModel (val userRepo: UserRepo) : ViewModel() {
    val loggedInUserProfile by lazy {
        userRepo.cachedLoggedInUserProfile!!
    }
    fun like(aid: Long, undo: Boolean) =
        Util.requestWithDeferredResultAsync(viewModelScope) {
            userRepo.like(loggedInUserProfile.id, aid, undo)
        }

    fun fav(aid: Long, undo: Boolean) =
        Util.requestWithDeferredResultAsync(viewModelScope) {
            userRepo.fav(loggedInUserProfile.id, aid, undo)
        }
}